package com.ruoyi.web.controller.mall.goodsClass.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.web.controller.mall.goodsClass.domain.GoodsClass;
import com.ruoyi.web.controller.mall.goodsClass.service.IGoodsClassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 商品分类Controller
 * 
 * @author ruoyi
 * @date 2021-01-18
 */
@RestController
@RequestMapping("/mall/goodsClass")
public class GoodsClassController extends BaseController
{
    @Autowired
    private IGoodsClassService goodsClassService;

    /**
     * 查询商品分类列表
     */
//    @RequiresPermissions("mall:goodsClass:list")
    @GetMapping("/getAll")
    public AjaxResult getAll()
    {
        List<GoodsClass> list = goodsClassService.getAll();
        if (list.size()>0){
            for (GoodsClass sc:list){
                List<GoodsClass> childList = goodsClassService.queryByParentId(sc.getId());
                sc.setChildList(childList);
            }
        }
        return AjaxResult.success(list);
    }

}
